package huanzhao.erp.domain.types;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

import javax.validation.constraints.NotNull;

/**
 * 可被分配任务的职位类型
 *
 * @author April
 * 2024/10/4 10:31
 * @version 1.0
 */
@Getter
public enum AssignablePositionType {
    WAREHOUSER("库管员"),
    PURCHASER("采购员"),
    REPAIR_LEADER("维修组长"),
    REPAIR("维修员"),
    TEAM_LEADER("渠道负责人"),
    TEAM_STAFF("渠道员工");


    @EnumValue
    @JsonValue
    private final String value;

    AssignablePositionType(String value) {
        this.value = value;
    }

    /**
     * 将任务类型转换为对应的职位类型
     *
     * @return AssignablePositionType
     * 2024/10/12 12:45:41
     */
    public static AssignablePositionType of(@NotNull TaskType taskType) {
        return switch (taskType) {
            // 库管
            case DISTRIBUTE, PURCHASE_RETURN, OUTSOURCE_REPAIR_SHIP, OUTSOURCE_REPAIR_SIGN, RECEIVE_REPAIR, STOCK,
                 SHIP_WHEN_SALE, HANDLE_RETURN, SIGN_FOR_AFTER_SALE, OUTBOUND_ONLY, TRANSFER,
                 SHIP_WHEN_AFTER_SALE_FINISHED -> WAREHOUSER;
            // 采购
            case FIRST_CHECK, PURCHASER_SEND_REPAIR, RECHECK, CHECK_AFTER_RETURN, CHECK_WHEN_TRANSFER,
                 RECEIVE_AFTER_SALE, RECEIVE_PUBLISH -> PURCHASER;
            // 维修组长
            case REPAIR_EVALUATE, DESIGNATE_REPAIR, FILL_OUTSOURCE_REPAIR_RESULT -> REPAIR_LEADER;
            // 维修员
            case REPAIR -> REPAIR;
            // 渠道负责人
            case DESIGNATE_QC -> TEAM_LEADER;
            // 渠道中普通员工
            case QC, ENTER, PUBLISH -> TEAM_STAFF;
        };
    }
}

